<%@ page import="java.util.ArrayList" %>
<%@ page import="entity.Teacher812" %><%--
  Created by IntelliJ IDEA.
  User: wang'ze'liang
  Date: 2021/8/12
  Time: 17:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/static/bootstrap-3.4.1-dist/css/bootstrap.css"/>
</head>
<body>
    <table class="table table-striped table-hover">
        <tr>
            <td>ID</td>
            <td>姓名</td>
            <td>年龄</td>
            <td>性别</td>
            <td>删除/修改</td>
        </tr>
        <%
            ArrayList<Teacher812> arrayList= (ArrayList<Teacher812>) request.getAttribute("T812");
            for (Teacher812 teacher812 : arrayList) {
        %>
        <tr>
            <td><%=teacher812.getTeacherId()%></td>
            <td><%=teacher812.getTeacherName()%></td>
            <td><%=teacher812.getAge()%></td>
            <td><%=teacher812.getGender()%></td>
            <td>
                <a class="btn btn-warning btn-sm" href="javascript:void(0)" onclick="deleteById(<%=teacher812.getTeacherId()%>)">删除</a>
                <a class="btn btn-success btn-sm" href="<%=request.getContextPath()%>/teacher812?te=selectById&id=<%=teacher812.getTeacherId()%>">修改</a>
            </td>
        </tr>
        <%
            }
        %>
    </table>
    <a class="btn btn-success" href="<%=request.getContextPath()%>/teacher812_insert.jsp">添加</a>
    <script type="text/javascript">
        function deleteById(id){
            var isDelete = confirm("确认删除")
            if (isDelete) {
                location.href = "<%=request.getContextPath()%>/teacher812?te=deleteById&id=" + id;
            }
        }

    </script>
</body>
</html>
